import { createRouter, createWebHistory } from 'vue-router';
import routes from './routes';
import { useStorage } from '@vueuse/core'
import { event } from 'vue-gtag'

const router = createRouter({
    history: createWebHistory(),
    routes: routes
})

router.beforeEach((to) => {
    const pageView = useStorage('pageview')
    if (typeof pageView.value === 'undefined') {
        pageView.value = 1
    } else {
        pageView.value++
    }
    event('pageview', {
        count: pageView.value
    })
})

export default router;